//
//  MortgageViewController.m
//  HouseShow
//
//  Created by gongjie on 11-12-27.
//  Copyright (c) 2011年 __MyCompanyName__. All rights reserved.
//

#import "MortgageViewController.h"

@implementation MortgageViewController
@synthesize m_CountBackGroundView;

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (id) init
{
    if ((self = [super init])) {
        UIButton* tBackBtt = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [tBackBtt setTitle:@"返回" forState:UIControlStateNormal];
        [tBackBtt addTarget:self action:@selector(disppearself) forControlEvents:UIControlEventTouchUpInside];
        tBackBtt.frame =CGRectMake(8,8, 48, 28);
        UIImageView* tTopView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hand.png"]];
        tTopView.userInteractionEnabled =YES;
        tTopView.frame =CGRectMake(0, 0, ScreenWidth-300, 44);
        [tTopView addSubview:tBackBtt];
        [self addSubview:tTopView];
        [tTopView release];
        
        [self setBackgroundColor:[UIColor whiteColor]];
        
        UIWebView* tWeb =[[UIWebView alloc] initWithFrame:CGRectZero];
        tWeb.tag =0x12;
        tWeb.frame = CGRectMake(30,44, ScreenWidth-360, ScreenHeight-44);
        NSString* tWebPath = [[NSBundle mainBundle] pathForResource:@"房贷计算器_公积金贷款计算器-搜房网2" ofType:@"htm"];
        NSLog(@"tWebPath =%@",tWebPath);
        NSData* tWebData = [NSData dataWithContentsOfFile:tWebPath];
        NSString *path = [[NSBundle mainBundle] bundlePath];
        NSURL *baseURL = [NSURL fileURLWithPath:path];
        NSLog(@"url =%@",baseURL);
        [tWeb loadData:tWebData MIMEType:nil textEncodingName:nil baseURL:baseURL];

        
        NSString* tWebJSPath = [[NSBundle mainBundle] pathForResource:@"calculate" ofType:@"js"];
        NSString* tJSContent = [NSString stringWithContentsOfFile:tWebJSPath encoding:NSUTF8StringEncoding error:nil];
        

        
        [tWeb stringByEvaluatingJavaScriptFromString:tJSContent];
        [self addSubview:tWeb];
        [tWeb release];
    }
    return self;
}

-(void) disppearself{
    [[self viewWithTag:0x12]resignFirstResponder];
    [m_CountBackGroundView removeFromSuperview];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.2];
    self.frame = CGRectMake(150, ScreenHeight, ScreenWidth-300, ScreenHeight);
    [UIView commitAnimations];
}

-(void) dealloc{
    [m_CountBackGroundView release];
    [super dealloc];
}

@end
